import http from '../utils/httpInstance'

// 资金类型
// 获取
export function serviceGetCapitalFlowType() {
  return http.get('/capitalFlowType')
}

// 删除
export function serviceDeleteCapitalFlowType(id: string) {
  return http.delete(`/capitalFlowType/${id}`, {
    headers: { successAlert: true },
  })
}

// 更新
export function serviceUpdateCapitalFlowType(id: string, data: object) {
  return http.put(`/capitalFlowType/${id}`, data, {
    headers: { successAlert: true },
  })
}

// 创建
export function serviceCreateCapitalFlowType(data: object) {
  return http.post('/capitalFlowType', data, {
    headers: { successAlert: true },
  })
}

// 资金流动
// 获取
export function serviceGetCapitalFlow(params?: object) {
  return http.get('/capitalFlow', { params })
}
// 删除
export function serviceDeleteCapitalFlow(id: string) {
  return http.delete(`/capitalFlow/${id}`, { headers: { successAlert: true } })
}
// 更新
export function serviceUpdateCapitalFlow(id: string, data: object) {
  return http.put(`/capitalFlow/${id}`, data, {
    headers: { successAlert: true },
  })
}
// 创建
export function serviceCreateCapitalFlow(data: object) {
  return http.post('/capitalFlow', data)
}

// 获取资金流动金额
// params:{起始时间，截止时间}
// 不传参数默认获取最近7天的数据
export function serviceGetCapitalFlowPrice(params?: object) {
  return http.get('/capitalFlow/price', { params })
}
